// pages/leftSwiperDel/index.js
var app=getApp()
Page({
  data: {
    delBtnWidth: 180,//删除按钮宽度单位（rpx）
    list:[]
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    this.initEleWidth();
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
    this.tempData();
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  
  //获取元素自适应后的实际宽度
  getEleWidth: function (w) {
    var real = 0;
    try {
      var res = wx.getSystemInfoSync().windowWidth;
      var scale = (750 / 2) / (w / 2);//以宽度750px设计稿做宽度的自适应
      // console.log(scale);
      real = Math.floor(res / scale);
      return real;
    } catch (e) {
      return false;
      // Do something when catch error
    }
  },
  initEleWidth: function () {
    var delBtnWidth = this.getEleWidth(this.data.delBtnWidth);
    this.setData({
      delBtnWidth: delBtnWidth
    });
  },
  tempData: function () {
    var list = [];
      var that=this;
    wx.request({
      url: 'https://tally.slickghost.com/demo2/Answer/selectRank',
      method: 'get',
      data: {
        openID: app.globalData.openid
      },
      success: function (res) {
        list=res.data;
        for(var i=0;i<list.length;i++){
          if (list[i].avatarUrl===""){
            list[i].avatarUrl ="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2966535430,1648563536&fm=27&gp=0.jpg";
          }
        }
        that.setData({
          list: list
        });
      }
    });
    //
    
  }
})